<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>驴迹短链</title>
  </head>
  <body>
  <h1><a id="user-content-short-url-service" class="anchor" href="#short-url-service" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>short-url-service</h1>
  <blockquote>
    <p>目的：简单造轮子 + 复习旧的知识</p>
  </blockquote>
  <h4><a id="user-content-项目介绍" class="anchor" href="#项目介绍" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>项目介绍</h4>
  <p>简单短链服务器,<a href="https://juejin.im/entry/5a5eee25518825733707ad6d">算法参考</a></p>
  <h4><a id="user-content-软件架构" class="anchor" href="#软件架构" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>软件架构</h4>
  <p><img src="./images/%E7%9F%AD%E9%93%BE%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%B5%81%E7%A8%8B.png" alt="流程图" /></p>
  <h4><a id="user-content-依赖" class="anchor" href="#依赖" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>依赖</h4>
  <ol>
    <li>servlet3.0+</li>
    <li>HikariCP</li>
    <li>Gson</li>
    <li>lettuce redis</li>
  </ol>
  <h4><a id="user-content-使用说明" class="anchor" href="#使用说明" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>使用说明</h4>
  <ol>
    <li>clone git</li>
    <li>gradle tomcatRun</li>
    <li>提供了短链生成API，使用token + json + post方式</li>
  </ol>
  <p>请求生成短链样例</p>
  <pre><code>短链生成请求：
curl -v -i -X POST -H &quot;Content-type:application/json&quot; -H &quot;token:123&quot; -d '{&quot;url&quot;:&quot;https://www.baidu.com&quot;}' http://localhost:8080/sus/create
短链生成响应：
* About to connect() to localhost port 8080 (#0)
*   Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
&gt; POST /sus/create HTTP/1.1
&gt; User-Agent: curl/7.29.0
&gt; Host: localhost:8080
&gt; Accept: */*
&gt; Content-type:application/json
&gt; token:123
&gt; Content-Length: 31
&gt;
* upload completely sent off: 31 out of 31 bytes
&lt; HTTP/1.1 200 OK
HTTP/1.1 200 OK
&lt; Server: Apache-Coyote/1.1
Server: Apache-Coyote/1.1
&lt; Content-Type: application/json;charset=UTF-8
Content-Type: application/json;charset=UTF-8
&lt; Transfer-Encoding: chunked
Transfer-Encoding: chunked
&lt; Date: Sat, 15 Dec 2018 09:05:28 GMT
Date: Sat, 15 Dec 2018 09:05:28 GMT

&lt;
{&quot;code&quot;:0,&quot;longUrl&quot;:&quot;https://www.baidu.com&quot;,&quot;shortUrl&quot;:&quot;Afi6Nb&quot;}
* Connection #0 to host localhost left intact
</code></pre>
  <p>使用短链访问样例</p>
  <pre><code>短链访问请求：
curl -v -i  http://localhost:8080/sus/vQj2eq
短链访问响应：
* About to connect() to localhost port 8080 (#0)
*   Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
&gt; GET /sus/vQj2eq HTTP/1.1
&gt; User-Agent: curl/7.29.0
&gt; Host: localhost:8080
&gt; Accept: */*
&gt;
&lt; HTTP/1.1 301 Moved Permanently
HTTP/1.1 301 Moved Permanently
&lt; Server: Apache-Coyote/1.1
Server: Apache-Coyote/1.1
&lt; Location: https://www.baidu.com
Location: https://www.baidu.com
&lt; Content-Length: 0
Content-Length: 0
&lt; Date: Sat, 15 Dec 2018 09:15:13 GMT
Date: Sat, 15 Dec 2018 09:15:13 GMT

&lt;
* Connection #0 to host localhost left intact
</code></pre>
  </body>
</html>
